﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace NSATBPortal
{
    public partial class MachineGroupCreate : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void cmdSave_Click(object sender, EventArgs e)
        {
            string sName = txtName.Text.Trim();
            string sDescription = txtDescription.Text.Trim();

            if (sName.Length == 0)
            {
                lblErrorMessage.Text = "ERROR: Name cannot be empty.";
            }
            else
            {
                int iIdentity = 0;
                string sUserID = Request.LogonUserIdentity.Name;
                using (ATBSchemaDB objATBDB = new ATBSchemaDB())
                {
                    iIdentity = objATBDB.CreateDefMachineGroup(sName, sDescription, sUserID);
                }
                if (iIdentity != 0)
                {
                    Response.Redirect("MachineGroupEditAssignments.aspx?ID=" + iIdentity.ToString() + "&Name=" + Server.UrlEncode(sName));
                }
                else
                {
                    Response.Redirect("MachineGroupHome.aspx");
                }
            }
        }

        protected void cmdCancel_Click(object sender, EventArgs e)
        {
            Response.Redirect("MachineGroupHome.aspx");
        }

    }
}